package com.example.shoppingdemo.goods;

import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;


import com.example.shoppingdemo.R;
import com.example.shoppingdemo.goods.MessageAdpter.MessgeAdapter;
import com.example.shoppingdemo.goods.model.UsersMsgModel;

import java.util.ArrayList;
import java.util.List;

public class mesgeActivity extends AppCompatActivity implements View.OnClickListener {

    private TextView msgall,msggood,msgbad,msgstyle,msgdefault,buygoods;
    private List<UsersMsgModel> usersMsgModelList = new ArrayList<>();
    private MessgeAdapter adapter;
    private Context context;
    private RecyclerView msgRecycler;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_mesge);
        initView();

        msgall = findViewById(R.id.msg_all);
        msggood = findViewById(R.id.msg_good);
        msgbad = findViewById(R.id.msg_bad);
        msgstyle = findViewById(R.id.msg_style);
        msgdefault = findViewById(R.id.msg_default);
        buygoods = findViewById(R.id.msg_goods_buy);
    }

    private void initView(){
        UsersMsgModel usersMsgModel = new UsersMsgModel();
        usersMsgModel.setImge(R.mipmap.qingtian);
        usersMsgModel.setName("泽泽123");
        usersMsgModel.setAddress("西安");
        usersMsgModel.setMessage("很好用，价格实惠，公道，便宜，感觉没有比这更好的了！");
        usersMsgModel.setData("五天前");
        usersMsgModel.setImges(R.mipmap.beibao);
        usersMsgModelList.add(usersMsgModel);
        UsersMsgModel usersMsgModel1 = new UsersMsgModel();
        usersMsgModel1.setImge(R.mipmap.duoyun);
        usersMsgModel1.setName("天天123");
        usersMsgModel1.setAddress("西安");
        usersMsgModel1.setMessage("实在太棒了，说句实话，真的好！");
        usersMsgModel1.setData("五天前");
        usersMsgModel1.setImges(R.mipmap.beibao);
        usersMsgModelList.add(usersMsgModel1);
        UsersMsgModel usersMsgModel2 = new UsersMsgModel();
        usersMsgModel2.setImge(R.mipmap.weather_splash);
        usersMsgModel2.setName("在世刘华强");
        usersMsgModel2.setAddress("北京");
        usersMsgModel2.setMessage("楼上两个明显是来刷好评的托吧，鉴定完毕；商家给我退钱，呀屎了你，信不信我砍你！");
        usersMsgModel2.setData("四天前");
        usersMsgModel2.setImges(R.mipmap.beibao);
        usersMsgModelList.add(usersMsgModel2);
        UsersMsgModel usersMsgModel3 = new UsersMsgModel();
        usersMsgModel3.setImge(R.mipmap.yutian);
        usersMsgModel3.setName("广东小诸葛");
        usersMsgModel3.setAddress("广东");
        usersMsgModel3.setMessage("楼上错了，那明显就是一个人刷的，不仅头像和名字差不多，tmd地址和时间一模一样，这商家怕不是请的小学生吧！");
        usersMsgModel3.setData("三天前");
        usersMsgModel3.setImges(R.mipmap.beibao);
        usersMsgModelList.add(usersMsgModel3);


        msgRecycler = findViewById(R.id.Recycler_evaluate_list);
        adapter = new MessgeAdapter(this);
        LinearLayoutManager la = new LinearLayoutManager(this);
        la.setOrientation(LinearLayoutManager.VERTICAL);
        msgRecycler.setLayoutManager(la);

        adapter.setMessgeModel(usersMsgModelList);
        msgRecycler.setAdapter(adapter);

    }

    @Override
    public void onClick(View view) {
        buygoods.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                Intent intent = new Intent(mesgeActivity.this,Goods_classify.class);
                startActivity(intent);
            }
        });
        msgdefault.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (msgdefault.getText() == "默认排序"){
                    msgdefault.setText("最新排序");
                }else {
                    msgdefault.setText("默认排序");
                }
            }
        });
    }
}